package com.sfh.cp.home.child.adapter;

import android.graphics.Color;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sfh.cp.R;
import com.sfh.cp.widget.WidgetLabelLayout;
import com.sfh.lib.AppCacheManager;
import com.squareup.picasso.Picasso;

import crm.sfh.server.entity.ETopic;
import crm.sfh.server.entity.EUser;

/**
 * 榜单
 */

public class RankingAdapter extends BaseQuickAdapter<EUser, BaseViewHolder> {
    public RankingAdapter() {
        super(R.layout.ranking_wealth_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, EUser item) {
        helper.setText(R.id.tvName, item.getName());
        helper.setText(R.id.tvContent, item.getSexText() + " " + item.getDegree() + " " + item.getAddress());

        ImageView iv = helper.getView(R.id.ivHead);
        if (TextUtils.isEmpty(item.getHead())) {
            iv.setImageResource(R.mipmap.userimg_default);
        } else {
            Picasso.with(AppCacheManager.getApplication()).load(item.getHead()).into(iv);
        }

        WidgetLabelLayout lbLyWealth = helper.getView(R.id.lbLyWealth);
        lbLyWealth.setStyleWealth(item.getWealth() + "");
        WidgetLabelLayout lbLyCharm = helper.getView(R.id.lbLyCharm);
        lbLyCharm.setStyleCharm(item.getCharm() + "");
        TextView tvIndex = helper.getView(R.id.tvIndex);
        int position = helper.getLayoutPosition();
        tvIndex.setText("NO." + (position + 1));
        if (position == 0) {
            tvIndex.setBackgroundResource(R.drawable.ranking_one);
            tvIndex.setTextColor(Color.WHITE);
        } else if (position == 1) {
            tvIndex.setBackgroundResource(R.drawable.ranking_two);
            tvIndex.setTextColor(Color.WHITE);
        } else if (position == 2) {
            tvIndex.setBackgroundResource(R.drawable.ranking_three);
            tvIndex.setTextColor(Color.WHITE);
        } else {
            tvIndex.setTextColor(Color.parseColor("$666666"));
        }
    }
}
